﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;

namespace ScraperEngine.Nodes
{
    internal class GetPageContent : ScraperMethodNode
    {
        public GetPageContent()
        {
            base.Type = NodeType.Method;
        }

        #region IScraperMethodNode Members

        public override string Invoke(params object[] list)
        {
            if (list.Length == 0)
            {
                Logging.Logger.LogMessage(Logging.MessageType.Error, "GetPageContent.Invoke", "No URI specified");
                return "";
            }
            System.Net.HttpWebRequest req = HttpWebRequest.Create(list[0]);
            StreamReader rdr = new StreamReader(req.GetResponse().GetResponseStream());
            return rdr.ReadToEnd();            
        }

        #endregion
    }
}
